import { defineStore } from 'pinia'
import { ref } from 'vue';
import {getRoleMsgData,getPostMsgData,getUserdepData} from '@/api/dataList.js'
import { getItem,setItem,removeItem } from '../utils';
export const useOrginStore = defineStore('message',
    () => {
       const roleMsgData = ref(getItem("roleMsgData") ||[])
       const postMsgData = ref( getItem("postMsgData") ||[])
       const userMsgData = ref( getItem("userMsgData") ||[])

const GetRoleMsgData = () => {
    getRoleMsgData().then(res => {
        roleMsgData.value = res.data
        setItem("roleMsgData",res.data)
    })
}

const GetPostMsgData = (data,transferValue) => {
    getPostMsgData().then(res => {
        postMsgData.value = res.data
        setItem("postMsgData",res.data)
    })
}

const GetUserMsgData = () => {
    getUserdepData().then(res => {
        userMsgData.value = res.data
        setItem("userMsgData",res.data.list)
    })
}

        return {
            roleMsgData,
            postMsgData,
            userMsgData,
            GetRoleMsgData,
            GetPostMsgData,
            GetUserMsgData
        }

    }
)